package com.fairytask.ui
{
	import com.fairytask.engine.components.ToolTips;
	import com.fairytask.engine.components.button.Button;
	import com.fairytask.engine.components.text.Label;
	import com.fairytask.managers.TipsManage;
	import com.fairytask.resource.StaticIni;
	import com.fairytask.ui.base.FrameUI;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 *竞技场对手信息 
	 * @author pangj
	 * 
	 */
	public class ArenaOppInfoUI extends FrameUI
	{
		public var level        :Label;   //对手等级
		public var rank         :Label;   //竞技场排名
		public var showInfo     :Button;  //查看对手按钮
		public var nameLabel    :Label;   //对手姓名 缩略
		private var nameTips    :String;  //对手姓名 全部
		private var nameID      :String;  //对手姓名 ID
		private var maskClick   :Sprite;  //点击热区
		
		public function ArenaOppInfoUI(popUI:Boolean=true)
		{
			super(popUI);
			init();
			initEvent();
		}
		private function init():void
		{
			maskClick = new Sprite();
			maskClick.graphics.clear();
			maskClick.graphics.beginFill(0,0);
			maskClick.graphics.drawRect(6,17,60,50);
			maskClick.graphics.endFill();
			windowBG.addChild(maskClick);
		}
		private function initEvent():void
		{
			showInfo.addEventListener(MouseEvent.CLICK,showOpperInfo);
			maskClick.addEventListener(MouseEvent.CLICK,fightOpper);
			maskClick.addEventListener(MouseEvent.ROLL_OVER,function(evt:MouseEvent):void{
				TipsManage.showTips(nameTips);
			});
			maskClick.addEventListener(MouseEvent.ROLL_OUT,function(evt:MouseEvent):void{
				ToolTips.hide();
			});
		}
		/**
		 *挑战对手 
		 * @param evt
		 * 
		 */
		private function fightOpper(evt:MouseEvent):void
		{
			ArenaUI.getInstance().hide();
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_BEG_AREAN,nameID);
		}
		/**
		 *查看对手信息
		 * @param evt
		 * 
		 */
		private function showOpperInfo(evt:MouseEvent):void
		{  
			ArenaUI.getInstance().nowOppName = nameTips;
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_CHECK_PLAYER,nameID);
		}
		/**
		 *设置对手信息 
		 * @param nameid  姓名
		 * @param rank    排名
		 * @param level   等级
		 * 
		 */
		public function setInfo(_nameid:String,_rank:String,_level:String):void
		{
			nameID = _nameid;
			nameTips = StaticIni.getSwfLangStr(nameID);
			nameLabel.htmlStr = nameTips;
			if(nameLabel.width > 67)
				nameLabel.htmlStr = nameTips.substr(0,4) + "...";
			nameLabel.x = int(16+windowBG.width - nameLabel.width)/2;
			
			level.htmlStrByBorder = StaticIni.getSwfLangStr("1000000062") + _level;
			rank.htmlStr = _rank;
			rank.x = int(16+windowBG.width - rank.width)/2;
		}
	}
}